const app = {
  state: {
    transitionName: 'slideLeft',
    isLoading: false
  },
  mutations: {
    SET_TRANSITION: (state, routerParams) =>{
      const {toDepth, fromDepth, toIndex, fromIndex} = routerParams

      if(toDepth === fromDepth){
        state.transitionName = toIndex < fromIndex ? 'vux-pop-out' : 'vux-pop-in'
      }else{
        state.transitionName = toDepth < fromDepth ? 'vux-pop-out' : 'vux-pop-in'
      }
    },
    UPDATE_LOADING_STATUS (state, payload) {
      state.isLoading = payload.isLoading
    }
  },
  actions: {
    setTransition: ({commit}, routerParams) =>{
      commit('SET_TRANSITION', routerParams)
    },
    updateLoadingStatus({commit}, payload){
      commit('UPDATE_LOADING_STATUS', payload)
    }
  }
}

export default app
